When I was a boy it was possible to get a "Captain Midnight Decoder Ring" by sending in twenty five cents (a whole quarter!!) and two labels from jars of Ovaltine. There were just two problems! I didn't have a quarter and my mother detested Ovaltine. But the mere idea of writing 'secret' messages always intrigued me. When I became older I learned that the simple substition crypts used on the decoder rings were anything but secure, indeed even as a boy reading Stevenson's 'Gold Bug' was convincing evidence of that.
The encryption scheme used in this stack is much more secure than the one used on the decoder rings. It is based on the idea of using a fairly long key and doing a bitwise exclusive OR (BXOR) between the character in the key and the character to be encrypted. As it happens by using the same algorithm and key decrypting the messages is done in exactly the same way. The problem is how to construct a key of sufficient length to be secure and, of course keeping it a secret. I will leave the latter to your own devising.
Fortunately constructing a fairly long key is moderately easy. If you serially encrypt your message with several keys which have different prime number lengths (and they meet other tests such as pseudo randomness and lack of repeats, BTW 'Mississippi' would be terrible) the length of the key is equal to the product of the length of the individual keys. So if you used three keys with lengths of 3, 5, and 7 the length of the effective key is 75.
On the encryption card each line in the 'Keys' box is treated as a seperate key. Using multiple keys does have a major draw back in that the time to encrypt goes up by multiples of the time for a single key. In this stack the encryption time is about 70 seconds/kbytes/key on a Macintosh II.
There are four XFCNs (BXOR, BAND, BOR, and BNOT) in this stack. They do the four basic bitwise Boolean manipulations of data ('and', 'or', 'exclusive or', and 'not'). In every case the operations accept scalars to 32 bits in size and return 32 bit results. All of the operations with the exception of the BNOT operator require two parameters. BNOT requires one parameter. The syntax for using these operators is;
BAND(arg1,arg2)
BOR(arg1,arg2)
BXOR(arg1,arg2)
BNOT(arg)
you would use them in a stack as follows
put BXOR(a,b) into it
As a final note if you want to return the negated value of a container smaller than 32 bits (say 8 bits) you can use the following;
put BAND(BNOT(a),(2^n-1)-1) into it
were n is the number of bits you wish to return (8 in our example).